package com.sgu6.sgu6_machine.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;

import com.sgu6.sgu6_machine.event.NetChangeEvent;
import com.sgu6.sgu6_machine.util.NetUtil;

import org.greenrobot.eventbus.EventBus;

import java.util.Objects;


public class NetBroadcastR extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        if (Objects.equals(intent.getAction(), ConnectivityManager.CONNECTIVITY_ACTION)) {
            int netWorkState = NetUtil.getNetWorkState(context);
            EventBus.getDefault().post(new NetChangeEvent(netWorkState));
        }
    }
}
